package com.rfy.user.service.impl;



import com.rfy.user.entity.User;
import com.rfy.user.mapper.UserMapper;
import com.rfy.user.request.UserLoginRequest;
import com.rfy.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: zhang
 * @date: 2019-07-19
 * @description：用户业务处理
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;


    @Override
    public Integer registUser(User user) {
        return userMapper.insertUser(user);
    }

    @Override
    public List<User> queryUserByAction(UserLoginRequest loginRequest) {
        return userMapper.selectUserByAction(loginRequest);
    }

    @Override
    public User selectUserById(Integer id) {
        return userMapper.selectUserById(id);
    }

    @Override
    public Integer updateUserInfoById(User user) {
        return userMapper.updateUserInfoById(user);
    }

    @Override
    public boolean queryIsHaveUser(User user) {
        Integer userCount = userMapper.selectUserByUsername(user);
        if (0 < userCount) {
            return true;
        }
        return false;
    }
}
